//
// Created by chizuru on 2025/9/2.
//

#pragma once


#include <cstdint>
#include <string>
#include <variant>
#include <vector>

struct ProtocolResult {
    bool ok;
    uint8_t errorCode;

    using CodecArg = std::variant<uint32_t, uint64_t, double, uint16_t, uint8_t, std::string>;
    std::vector<CodecArg> values;
    // useful for debugging or re-parsing
    std::vector<uint8_t> raw;
    static ProtocolResult Fail(uint8_t err = 0) { return ProtocolResult{false, err, {}, {}}; }
    static ProtocolResult Ok(std::vector<CodecArg> vals = {}, std::vector<uint8_t> rawBytes = {}) {
        return ProtocolResult{true, 0, std::move(vals), std::move(rawBytes)};
    }
};
